package com.itheima.exception;


import com.itheima.support.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author YYP
 * @date 2020/12/2
 */
@RestControllerAdvice
public class GlobalExceptionInvoker {

    @ExceptionHandler
    public Result handleException(Exception ex){
        String message = ex.getMessage();
        if(message.length() > 200){
            message = message.substring(0,200);
        }
        return new Result(false,message);

    }
}
